<!DOCTYPE html>
<HTML>
<HEAD>
	<meta charset="utf-8">
    <title>区域管理</title>
    <script type="text/javascript" charset="UTF-8" src="../../../../static/js/header_base.js"></script>
    <script type="text/javascript" charset="UTF-8" src="../../../../static/js/header_ztree.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../../../static/js/header_com.js"></script>	
	<script type="text/javascript">	
		var layer;var ztreeObj;
		layui.config({
			base : "../../../../static/js/"
		}).extend({
			"application" : "application",
			"publicUtil" : "publicUtil"
		})
		layui.use(['layer','application',"publicUtil"],function(){
			layer = parent.layer,
			application = layui.application,
			_$ = layui.jquery,
			publicUtil  = layui.publicUtil;
			//ztree设置
			var setting = {
					view: {
							selectedMulti: false
					},

					data: {
							simpleData: {
									enable: true,
									idKey: "id",
									pIdKey: "parentId"
							}
					},
					check: {
						enable: true,
						chkStyle: "radio",  //单选框
						radioType: "all"   //对所有节点设置单选
					}
			};

			_$(document).ready(function(){
				//重置按钮
				//生产环境具体考虑
				$("#reset").click(function(){
					ztreeObj.checkAllNodes(true);
				});
				
				
				_$.ajax({
					url: application.SERVE_URL+'/sys/sysarea/tree',                  //ajax请求地址
					headers : { 'Authorization' : application.HEADER},
					success: function (data) {	
						ztreeObj = $.fn.zTree.init($("#treeDemo"), setting, data.data);  //加载数据
						publicUtil.setTreeSel($(".parentId",parent.document).val(),ztreeObj);
					}
				 });	
				 
				_$("#getSelectData").click(function(){
					 publicUtil.setAcrossName(ztreeObj.getCheckedNodes(),".parentId",".parentName")

				 })
			});

 		});	
	</script>
</HEAD>

<BODY class="childrenBody">
		<div>
			<ul id="treeDemo" class="ztree"></ul>
		</div>
		<div class="layui-form-item layui-row layui-col-xs12" style="float: right; bottom: 10px; position:fixed;">
			<div class="layui-input-block" style="margin-bottom: 10px;">
				<a class="layui-btn layui-btn-sm" lay-submit="" lay-filter="getSelectData" id="getSelectData">确认</a>
				<a  class="layui-btn layui-btn-sm layui-btn-primary" id="reset">重置</a>
			</div>
<!-- 			<a class="layui-btn layui-btn-xs" lay-submit="getSelectData">确认</a>
			<a type="reset" class="layui-btn layui-btn-xs layui-btn-danger" onclick="reset(	)">重置</a>	 -->		
		</div>
</BODY>
</HTML>